# Copyright 2019 The MediaPipe Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

licenses(["notice"])  # Apache 2.0

package(default_visibility = ["//visibility:private"])

load("//mediapipe/framework/port:build_config.bzl", "mediapipe_cc_proto_library")

proto_library(
    name = "color_proto",
    srcs = ["color.proto"],
    visibility = ["//visibility:public"],
)

proto_library(
    name = "render_data_proto",
    srcs = ["render_data.proto"],
    visibility = ["//visibility:public"],
    deps = ["//mediapipe/util:color_proto"],
)

mediapipe_cc_proto_library(
    name = "color_cc_proto",
    srcs = ["color.proto"],
    visibility = ["//visibility:public"],
    deps = [":color_proto"],
)

mediapipe_cc_proto_library(
    name = "render_data_cc_proto",
    srcs = ["render_data.proto"],
    cc_deps = [":color_cc_proto"],
    visibility = ["//mediapipe:__subpackages__"],
    deps = [":render_data_proto"],
)

cc_library(
    name = "cpu_util",
    srcs = ["cpu_util.cc"],
    hdrs = ["cpu_util.h"],
    visibility = [
        "//mediapipe/framework:mediapipe_internal",
    ],
    deps = [
        "@com_google_absl//absl/algorithm:container",
        "@com_google_absl//absl/strings",
        "//mediapipe/framework/port:integral_types",
        "//mediapipe/framework:port",
        "//mediapipe/framework/port:status",
        "//mediapipe/framework/port:statusor",
    ] + select({
        "//conditions:default": [],
        "//mediapipe:android": [
            "@androidndk//:cpufeatures",
        ],
    }),
)

cc_library(
    name = "header_util",
    srcs = ["header_util.cc"],
    hdrs = ["header_util.h"],
    visibility = [
        "//mediapipe/framework:mediapipe_internal",
    ],
    deps = [
        "//mediapipe/framework:calculator_framework",
        "//mediapipe/framework:packet_set",
        "//mediapipe/framework/port:status",
        "//mediapipe/framework/tool:status_util",
    ],
)

cc_library(
    name = "image_frame_util",
    srcs = ["image_frame_util.cc"],
    hdrs = ["image_frame_util.h"],
    visibility = [
        "//visibility:public",
    ],
    deps = [
        "//mediapipe/framework/deps:mathutil",
        "//mediapipe/framework/formats:image_format_cc_proto",
        "//mediapipe/framework/formats:image_frame",
        "//mediapipe/framework/formats:image_frame_opencv",
        "//mediapipe/framework/formats:yuv_image",
        "//mediapipe/framework/port",
        "//mediapipe/framework/port:integral_types",
        "//mediapipe/framework/port:logging",
        "//mediapipe/framework/port:opencv_imgproc",
        "//mediapipe/framework/port:status",
        "//mediapipe/framework/tool:status_util",
        "@com_google_absl//absl/strings",
        "@libyuv",
    ],
)

cc_library(
    name = "annotation_renderer",
    srcs = ["annotation_renderer.cc"],
    hdrs = ["annotation_renderer.h"],
    visibility = [
        "//visibility:public",
    ],
    deps = [
        ":render_data_cc_proto",
        "//mediapipe/framework/port:logging",
        "//mediapipe/framework/port:opencv_core",
        "//mediapipe/framework/port:opencv_imgproc",
        "//mediapipe/framework/port:vector",
        "//mediapipe/util:color_cc_proto",
    ],
)

cc_library(
    name = "resource_util",
    srcs = select({
        "//conditions:default": ["resource_util.cc"],
        "//mediapipe:android": ["resource_util_android.cc"],
    }),
    hdrs = ["resource_util.h"],
    # We use Objective-C++ on iOS.
    visibility = [
        "//mediapipe/framework:mediapipe_internal",
    ],
    deps = [
        "//mediapipe/framework/port:ret_check",
        "//mediapipe/framework/port:status",
        "//mediapipe/framework/port:statusor",
        "@com_google_absl//absl/strings",
    ] + select({
        "//conditions:default": [
            "//mediapipe/framework/port:file_helpers",
        ],
        "//mediapipe:android": [
            "//mediapipe/util/android:asset_manager_util",
            "//mediapipe/util/android/file/base",
        ],
    }),
)

cc_library(
    name = "tensor_to_detection",
    srcs = ["tensor_to_detection.cc"],
    hdrs = ["tensor_to_detection.h"],
    features = [
        # Layering check doesn't play nicely with portable proto wrappers.
        "no_layering_check",
    ],
    visibility = [
        "//visibility:public",
    ],
    deps = [
        "//mediapipe/framework/formats:detection_cc_proto",
        "//mediapipe/framework/formats:location",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/types:variant",
        "//mediapipe/framework/port:status",
        "//mediapipe/framework/port:map_util",
    ] + select({
        "//conditions:default": [
            "@org_tensorflow//tensorflow/core:framework",
        ],
        "//mediapipe:android": [
            "@org_tensorflow//tensorflow/core:android_tensorflow_lib_lite",
        ],
    }),
)
